home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / readline-2.0mg.tar.gz / readline-2.0mg.tar / readline-2.0mg / doc / readline.info-1 (.txt) < prev    next >
GNU Info File  |  1994-08-03  |  50KB  |  956 lines

  1. This is Info file readline.info, produced by Makeinfo-1.55 from the
  2. input file rlman.texinfo.
  3.    This document describes the GNU Readline Library, a utility which
  4. aids in the consistency of user interface across discrete programs that
  5. need to provide a command line interface.
  6.    Copyright (C) 1988, 1991 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice pare
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that this permission notice may be stated in a
  17. translation approved by the Foundation.
  18. File: readline.info,  Node: Top,  Next: Command Line Editing,  Prev: (DIR),  Up: (DIR)
  19. GNU Readline Library
  20. ********************
  21.    This document describes the GNU Readline Library, a utility which
  22. aids in the consistency of user interface across discrete programs that
  23. need to provide a command line interface.
  24. * Menu:
  25. * Command Line Editing::       GNU Readline User's Manual.
  26. * Programming with GNU Readline::  GNU Readline Programmer's Manual.
  27. * Concept Index::           Index of concepts described in this manual.
  28. * Function and Variable Index::       Index of externally visible functions
  29.                    and variables.
  30. File: readline.info,  Node: Command Line Editing,  Next: Programming with GNU Readline,  Prev: Top,  Up: Top
  31. Command Line Editing
  32. ********************
  33.    This chapter describes the basic features of the GNU command line
  34. editing interface.
  35. * Menu:
  36. * Introduction and Notation::    Notation used in this text.
  37. * Readline Interaction::    The minimum set of commands for editing a line.
  38. * Readline Init File::        Customizing Readline from a user's view.
  39. * Bindable Readline Commands::    A description of most of the Readline commands
  40.                 available for binding
  41. * Readline vi Mode::        A short description of how to make Readline
  42.                 behave like the vi editor.
  43. File: readline.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
  44. Introduction to Line Editing
  45. ============================
  46.    The following paragraphs describe the notation used to represent
  47. keystrokes.
  48.    The text C-k is read as `Control-K' and describes the character
  49. produced when the Control key is depressed and the k key is struck.
  50.    The text M-k is read as `Meta-K' and describes the character
  51. produced when the meta key (if you have one) is depressed, and the k
  52. key is struck.  If you do not have a meta key, the identical keystroke
  53. can be generated by typing ESC first, and then typing k.  Either
  54. process is known as "metafying" the k key.
  55.    The text M-C-k is read as `Meta-Control-k' and describes the
  56. character produced by "metafying" C-k.
  57.    In addition, several keys have their own names.  Specifically, DEL,
  58. ESC, LFD, SPC, RET, and TAB all stand for themselves when seen in this
  59. text, or in an init file (*note Readline Init File::., for more info).
  60. File: readline.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
  61. Readline Interaction
  62. ====================
  63.    Often during an interactive session you type in a long line of text,
  64. only to notice that the first word on the line is misspelled.  The
  65. Readline library gives you a set of commands for manipulating the text
  66. as you type it in, allowing you to just fix your typo, and not forcing
  67. you to retype the majority of the line.  Using these editing commands,
  68. you move the cursor to the place that needs correction, and delete or
  69. insert the text of the corrections.  Then, when you are satisfied with
  70. the line, you simply press RETURN.  You do not have to be at the end of
  71. the line to press RETURN; the entire line is accepted regardless of the
  72. location of the cursor within the line.
  73. * Menu:
  74. * Readline Bare Essentials::    The least you need to know about Readline.
  75. * Readline Movement Commands::    Moving about the input line.
  76. * Readline Killing Commands::    How to delete text, and how to get it back!
  77. * Readline Arguments::        Giving numeric arguments to commands.
  78. File: readline.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
  79. Readline Bare Essentials
  80. ------------------------
  81.    In order to enter characters into the line, simply type them.  The
  82. typed character appears where the cursor was, and then the cursor moves
  83. one space to the right.  If you mistype a character, you can use your
  84. erase character to back up and delete the mistyped character.
  85.    Sometimes you may miss typing a character that you wanted to type,
  86. and not notice your error until you have typed several other
  87. characters.  In that case, you can type C-b to move the cursor to the
  88. left, and then correct your mistake.  Afterwards, you can move the
  89. cursor to the right with C-f.
  90.    When you add text in the middle of a line, you will notice that
  91. characters to the right of the cursor are `pushed over' to make room
  92. for the text that you have inserted.  Likewise, when you delete text
  93. behind the cursor, characters to the right of the cursor are `pulled
  94. back' to fill in the blank space created by the removal of the text.  A
  95. list of the basic bare essentials for editing the text of an input line
  96. follows.
  97.      Move back one character.
  98.      Move forward one character.
  99.      Delete the character to the left of the cursor.
  100.      Delete the character underneath the cursor.
  101. Printing characters
  102.      Insert the character into the line at the cursor.
  103.      Undo the last thing that you did.  You can undo all the way back
  104.      to an empty line.
  105. File: readline.info,  Node: Readline Movement Commands,  Next: Readline Killing Commands,  Prev: Readline Bare Essentials,  Up: Readline Interaction
  106. Readline Movement Commands
  107. --------------------------
  108.    The above table describes the most basic possible keystrokes that
  109. you need in order to do editing of the input line.  For your
  110. convenience, many other commands have been added in addition to C-b,
  111. C-f, C-d, and DEL.  Here are some commands for moving more rapidly
  112. about the line.
  113.      Move to the start of the line.
  114.      Move to the end of the line.
  115.      Move forward a word.
  116.      Move backward a word.
  117.      Clear the screen, reprinting the current line at the top.
  118.    Notice how C-f moves forward a character, while M-f moves forward a
  119. word.  It is a loose convention that control keystrokes operate on
  120. characters while meta keystrokes operate on words.
  121. File: readline.info,  Node: Readline Killing Commands,  Next: Readline Arguments,  Prev: Readline Movement Commands,  Up: Readline Interaction
  122. Readline Killing Commands
  123. -------------------------
  124.    "Killing" text means to delete the text from the line, but to save
  125. it away for later use, usually by "yanking" (re-inserting) it back into
  126. the line.  If the description for a command says that it `kills' text,
  127. then you can be sure that you can get the text back in a different (or
  128. the same) place later.
  129.    When you use a kill command, the text is saved in a "kill-ring".
  130. Any number of consecutive kills save all of the killed text together, so
  131. that when you yank it back, you get it all.  The kill ring is not line
  132. specific; the text that you killed on a previously typed line is
  133. available to be yanked back later, when you are typing another line.
  134.    Here is the list of commands for killing text.
  135.      Kill the text from the current cursor position to the end of the
  136.      line.
  137.      Kill from the cursor to the end of the current word, or if between
  138.      words, to the end of the next word.
  139. M-DEL
  140.      Kill from the cursor the start of the previous word, or if between
  141.      words, to the start of the previous word.
  142.      Kill from the cursor to the previous whitespace.  This is
  143.      different than M-DEL because the word boundaries differ.
  144.    And, here is how to "yank" the text back into the line.  Yanking
  145. means to copy the most-recently-killed text from the kill buffer.
  146.      Yank the most recently killed text back into the buffer at the
  147.      cursor.
  148.      Rotate the kill-ring, and yank the new top.  You can only do this
  149.      if the prior command is C-y or M-y.
  150. File: readline.info,  Node: Readline Arguments,  Prev: Readline Killing Commands,  Up: Readline Interaction
  151. Readline Arguments
  152. ------------------
  153.    You can pass numeric arguments to Readline commands.  Sometimes the
  154. argument acts as a repeat count, other times it is the sign of the
  155. argument that is significant.  If you pass a negative argument to a
  156. command which normally acts in a forward direction, that command will
  157. act in a backward direction.  For example, to kill text back to the
  158. start of the line, you might type M- C-k.
  159.    The general way to pass numeric arguments to a command is to type
  160. meta digits before the command.  If the first `digit' you type is a
  161. minus sign (-), then the sign of the argument will be negative.  Once
  162. you have typed one meta digit to get the argument started, you can type
  163. the remainder of the digits, and then the command.  For example, to give
  164. the C-d command an argument of 10, you could type M-1 0 C-d.
  165. File: readline.info,  Node: Readline Init File,  Next: Bindable Readline Commands,  Prev: Readline Interaction,  Up: Command Line Editing
  166. Readline Init File
  167. ==================
  168.    Although the Readline library comes with a set of Emacs-like
  169. keybindings installed by default, it is possible that you would like to
  170. use a different set of keybindings.  You can customize programs that
  171. use Readline by putting commands in an "init" file in your home
  172. directory.  The name of this file is taken from the value of the
  173. environment variable `INPUTRC'.  If that variable is unset, the default
  174. is `~/.inputrc'.
  175.    When a program which uses the Readline library starts up, the init
  176. file is read, and the key bindings are set.
  177.    In addition, the `C-x C-r' command re-reads this init file, thus
  178. incorporating any changes that you might have made to it.
  179. * Menu:
  180. * Readline Init Syntax::    Syntax for the commands in the inputrc file.
  181. * Conditional Init Constructs::    Conditional key bindings in the inputrc file.
  182. File: readline.info,  Node: Readline Init Syntax,  Next: Conditional Init Constructs,  Up: Readline Init File
  183. Readline Init Syntax
  184. --------------------
  185.    There are only a few basic constructs allowed in the Readline init
  186. file.  Blank lines are ignored.  Lines beginning with a # are comments.
  187. Lines beginning with a $ indicate conditional constructs (*note
  188. Conditional Init Constructs::.).  Other lines denote variable settings
  189. and key bindings.
  190. Variable Settings
  191.      You can change the state of a few variables in Readline by using
  192.      the `set' command within the init file.  Here is how you would
  193.      specify that you wish to use `vi' line editing commands:
  194.           set editing-mode vi
  195.      Right now, there are only a few variables which can be set; so
  196.      few, in fact, that we just list them here:
  197.     `editing-mode'
  198.           The `editing-mode' variable controls which editing mode you
  199.           are using.  By default, Readline starts up in Emacs editing
  200.           mode, where the keystrokes are most similar to Emacs.  This
  201.           variable can be set to either `emacs' or `vi'.
  202.     `horizontal-scroll-mode'
  203.           This variable can be set to either `On' or `Off'.  Setting it
  204.           to `On' means that the text of the lines that you edit will
  205.           scroll horizontally on a single screen line when they are
  206.           longer than the width of the screen, instead of wrapping onto
  207.           a new screen line.  By default, this variable is set to `Off'.
  208.     `mark-modified-lines'
  209.           This variable, when set to `On', says to display an asterisk
  210.           (`*') at the start of history lines which have been modified.
  211.           This variable is `off' by default.
  212.     `bell-style'
  213.           Controls what happens when Readline wants to ring the
  214.           terminal bell.  If set to `none', Readline never rings the
  215.           bell.  If set to `visible', Readline uses a visible bell if
  216.           one is available.  If set to `audible' (the default),
  217.           Readline attempts to ring the terminal's bell.
  218.     `comment-begin'
  219.           The string to insert at the beginning of the line when the
  220.           `vi-comment' command is executed.  The default value is `"#"'.
  221.     `meta-flag'
  222.           If set to `on', Readline will enable eight-bit input (it will
  223.           not strip the eighth bit from the characters it reads),
  224.           regardless of what the terminal claims it can support.  The
  225.           default value is `off'.
  226.     `convert-meta'
  227.           If set to `on', Readline will convert characters with the
  228.           eigth bit set to an ASCII key sequence by stripping the eigth
  229.           bit and prepending an ESC character, converting them to a
  230.           meta-prefixed key sequence.  The default value is `on'.
  231.     `output-meta'
  232.           If set to `on', Readline will display characters with the
  233.           eighth bit set directly rather than as a meta-prefixed escape
  234.           sequence.  The default is `off'.
  235.     `completion-query-items'
  236.           The number of possible completions that determines when the
  237.           user is asked whether he wants to see the list of
  238.           possibilities.  If the number of possible completions is
  239.           greater than this value, Readline will ask the user whether
  240.           or not he wishes to view them; otherwise, they are simply
  241.           listed.  The default limit is `100'.
  242.     `keymap'
  243.           Sets Readline's idea of the current keymap for key binding
  244.           commands.  Acceptable `keymap' names are `emacs',
  245.           `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
  246.           `vi-command', and `vi-insert'.  `vi' is equivalent to
  247.           `vi-command'; `emacs' is equivalent to `emacs-standard'.  The
  248.           default value is `emacs'.  The value of the `editing-mode'
  249.           variable also affects the default keymap.
  250.     `show-all-if-ambiguous'
  251.           This alters the default behavior of the completion functions.
  252.           If set to `on', words which have more than one possible
  253.           completion cause the matches to be listed immediately instead
  254.           of ringing the bell.  The default value is `off'.
  255.     `expand-tilde'
  256.           If set to `on', tilde expansion is performed when Readline
  257.           attempts word completion.  The default is `off'.
  258. Key Bindings
  259.      The syntax for controlling key bindings in the init file is
  260.      simple.  First you have to know the name of the command that you
  261.      want to change.  The following pages contain tables of the command
  262.      name, the default keybinding, and a short description of what the
  263.      command does.
  264.      Once you know the name of the command, simply place the name of
  265.      the key you wish to bind the command to, a colon, and then the
  266.      name of the command on a line in the init file.  The name of the
  267.      key can be expressed in different ways, depending on which is most
  268.      comfortable for you.
  269.     KEYNAME: FUNCTION-NAME or MACRO
  270.           KEYNAME is the name of a key spelled out in English.  For
  271.           example:
  272.                Control-u: universal-argument
  273.                Meta-Rubout: backward-kill-word
  274.                Control-o: ">&output"
  275.           In the above example, `C-u' is bound to the function
  276.           `universal-argument', and `C-o' is bound to run the macro
  277.           expressed on the right hand side (that is, to insert the text
  278.           `>&output' into the line).
  279.     "KEYSEQ": FUNCTION-NAME or MACRO
  280.           KEYSEQ differs from KEYNAME above in that strings denoting an
  281.           entire key sequence can be specified, by placing the key
  282.           sequence in double quotes.  Some GNU Emacs style key escapes
  283.           can be used, as in the following example, but the special
  284.           character names are not recognized.
  285.                "\C-u": universal-argument
  286.                "\C-x\C-r": re-read-init-file
  287.                "\e[11~": "Function Key 1"
  288.           In the above example, `C-u' is bound to the function
  289.           `universal-argument' (just as it was in the first example),
  290.           `C-x C-r' is bound to the function `re-read-init-file', and
  291.           `ESC [ 1 1 ~' is bound to insert the text `Function Key 1'.
  292.           The following escape sequences are available when specifying
  293.           key sequences:
  294.          ``\C-''
  295.                control prefix
  296.          ``\M-''
  297.                meta prefix
  298.          ``\e''
  299.                an escape character
  300.          ``\\''
  301.                backslash
  302.          ``\"''
  303.                "
  304.          ``\'''
  305.                '
  306.           When entering the text of a macro, single or double quotes
  307.           should be used to indicate a macro definition.  Unquoted text
  308.           is assumed to be a function name.  Backslash will quote any
  309.           character in the macro text, including " and '.  For example,
  310.           the following binding will make `C-x \' insert a single \
  311.           into the line:
  312.                "\C-x\\": "\\"
  313. File: readline.info,  Node: Conditional Init Constructs,  Prev: Readline Init Syntax,  Up: Readline Init File
  314. Conditional Init Constructs
  315. ---------------------------
  316.    Readline implements a facility similar in spirit to the conditional
  317. compilation features of the C preprocessor which allows key bindings
  318. and variable settings to be performed as the result of tests.  There
  319. are three parser directives used.
  320. `$if'
  321.      The `$if' construct allows bindings to be made based on the
  322.      editing mode, the terminal being used, or the application using
  323.      Readline.  The text of the test extends to the end of the line; no
  324.      characters are required to isolate it.
  325.     `mode'
  326.           The `mode=' form of the `$if' directive is used to test
  327.           whether Readline is in `emacs' or `vi' mode.  This may be
  328.           used in conjunction with the `set keymap' command, for
  329.           instance, to set bindings in the `emacs-standard' and
  330.           `emacs-ctlx' keymaps only if Readline is starting out in
  331.           `emacs' mode.
  332.     `term'
  333.           The `term=' form may be used to include terminal-specific key
  334.           bindings, perhaps to bind the key sequences output by the
  335.           terminal's function keys.  The word on the right side of the
  336.           `=' is tested against the full name of the terminal and the
  337.           portion of the terminal name before the first `-'.  This
  338.           allows SUN to match both SUN and SUN-CMD, for instance.
  339.     `application'
  340.           The APPLICATION construct is used to include
  341.           application-specific settings.  Each program using the
  342.           Readline library sets the APPLICATION NAME, and you can test
  343.           for it.  This could be used to bind key sequences to
  344.           functions useful for a specific program.  For instance, the
  345.           following command adds a key sequence that quotes the current
  346.           or previous word in Bash:
  347.                $if bash
  348.                # Quote the current or previous word
  349.                "\C-xq": "\eb\"\ef\""
  350.                $endif
  351. `$endif'
  352.      This command, as you saw in the previous example, terminates an
  353.      `$if' command.
  354. `$else'
  355.      Commands in this branch of the `$if' directive are executed if the
  356.      test fails.
  357. File: readline.info,  Node: Bindable Readline Commands,  Next: Readline vi Mode,  Prev: Readline Init File,  Up: Command Line Editing
  358. Bindable Readline Commands
  359. ==========================
  360. * Menu:
  361. * Commands For Moving::        Moving about the line.
  362. * Commands For History::    Getting at previous lines.
  363. * Commands For Text::        Commands for changing text.
  364. * Commands For Killing::    Commands for killing and yanking.
  365. * Numeric Arguments::        Specifying numeric arguments, repeat counts.
  366. * Commands For Completion::    Getting Readline to do the typing for you.
  367. * Keyboard Macros::        Saving and re-executing typed characters
  368. * Miscellaneous Commands::    Other miscellaneous commands.
  369. File: readline.info,  Node: Commands For Moving,  Next: Commands For History,  Up: Bindable Readline Commands
  370. Commands For Moving
  371. -------------------
  372. `beginning-of-line (C-a)'
  373.      Move to the start of the current line.
  374. `end-of-line (C-e)'
  375.      Move to the end of the line.
  376. `forward-char (C-f)'
  377.      Move forward a character.
  378. `backward-char (C-b)'
  379.      Move back a character.
  380. `forward-word (M-f)'
  381.      Move forward to the end of the next word.  Words are composed of
  382.      letters and digits.
  383. `backward-word (M-b)'
  384.      Move back to the start of this, or the previous, word.  Words are
  385.      composed of letters and digits.
  386. `clear-screen (C-l)'
  387.      Clear the screen and redraw the current line, leaving the current
  388.      line at the top of the screen.
  389. `redraw-current-line ()'
  390.      Refresh the current line.  By default, this is unbound.
  391. File: readline.info,  Node: Commands For History,  Next: Commands For Text,  Prev: Commands For Moving,  Up: Bindable Readline Commands
  392. Commands For Manipulating The History
  393. -------------------------------------
  394. `accept-line (Newline, Return)'
  395.      Accept the line regardless of where the cursor is.  If this line is
  396.      non-empty, add it to the history list.  If this line was a history
  397.      line, then restore the history line to its original state.
  398. `previous-history (C-p)'
  399.      Move `up' through the history list.
  400. `next-history (C-n)'
  401.      Move `down' through the history list.
  402. `beginning-of-history (M-<)'
  403.      Move to the first line in the history.
  404. `end-of-history (M->)'
  405.      Move to the end of the input history, i.e., the line you are
  406.      entering.
  407. `reverse-search-history (C-r)'
  408.      Search backward starting at the current line and moving `up'
  409.      through the history as necessary.  This is an incremental search.
  410. `forward-search-history (C-s)'
  411.      Search forward starting at the current line and moving `down'
  412.      through the the history as necessary.  This is an incremental
  413.      search.
  414. `non-incremental-reverse-search-history (M-p)'
  415.      Search backward starting at the current line and moving `up'
  416.      through the history as necessary using a non-incremental search
  417.      for a string supplied by the user.
  418. `non-incremental-forward-search-history (M-n)'
  419.      Search forward starting at the current line and moving `down'
  420.      through the the history as necessary using a non-incremental search
  421.      for a string supplied by the user.
  422. `history-search-forward ()'
  423.      Search forward through the history for the string of characters
  424.      between the start of the current line and the current point.  This
  425.      is a non-incremental search.  By default, this command is unbound.
  426. `history-search-backward ()'
  427.      Search backward through the history for the string of characters
  428.      between the start of the current line and the current point.  This
  429.      is a non-incremental search.  By default, this command is unbound.
  430. `yank-nth-arg (M-C-y)'
  431.      Insert the first argument to the previous command (usually the
  432.      second word on the previous line).  With an argument N, insert the
  433.      Nth word from the previous command (the words in the previous
  434.      command begin with word 0).  A negative argument inserts the Nth
  435.      word from the end of the previous command.
  436. `yank-last-arg (M-., M-_)'
  437.      Insert last argument to the previous command (the last word on the
  438.      previous line).  With an argument, behave exactly like
  439.      `yank-nth-arg'.
  440. File: readline.info,  Node: Commands For Text,  Next: Commands For Killing,  Prev: Commands For History,  Up: Bindable Readline Commands
  441. Commands For Changing Text
  442. --------------------------
  443. `delete-char (C-d)'
  444.      Delete the character under the cursor.  If the cursor is at the
  445.      beginning of the line, there are no characters in the line, and
  446.      the last character typed was not C-d, then return EOF.
  447. `backward-delete-char (Rubout)'
  448.      Delete the character behind the cursor.  A numeric arg says to kill
  449.      the characters instead of deleting them.
  450. `quoted-insert (C-q, C-v)'
  451.      Add the next character that you type to the line verbatim.  This is
  452.      how to insert key sequences like C-q, for example.
  453. `tab-insert (M-TAB)'
  454.      Insert a tab character.
  455. `self-insert (a, b, A, 1, !, ...)'
  456.      Insert yourself.
  457. `transpose-chars (C-t)'
  458.      Drag the character before the cursor forward over the character at
  459.      the cursor, moving the cursor forward as well.  If the insertion
  460.      point is at the end of the line, then this transposes the last two
  461.      characters of the line.  Negative argumentss don't work.
  462. `transpose-words (M-t)'
  463.      Drag the word behind the cursor past the word in front of the
  464.      cursor moving the cursor over that word as well.
  465. `upcase-word (M-u)'
  466.      Uppercase the current (or following) word.  With a negative
  467.      argument, do the previous word, but do not move the cursor.
  468. `downcase-word (M-l)'
  469.      Lowercase the current (or following) word.  With a negative
  470.      argument, do the previous word, but do not move the cursor.
  471. `capitalize-word (M-c)'
  472.      Capitalize the current (or following) word.  With a negative
  473.      argument, do the previous word, but do not move the cursor.
  474. File: readline.info,  Node: Commands For Killing,  Next: Numeric Arguments,  Prev: Commands For Text,  Up: Bindable Readline Commands
  475. Killing And Yanking
  476. -------------------
  477. `kill-line (C-k)'
  478.      Kill the text from the current cursor position to the end of the
  479.      line.
  480. `backward-kill-line (C-x Rubout)'
  481.      Kill backward to the beginning of the line.
  482. `unix-line-discard (C-u)'
  483.      Kill backward from the cursor to the beginning of the current line.
  484.      Save the killed text on the kill-ring.
  485. `kill-whole-line ()'
  486.      Kill all characters on the current line, no matter where the
  487.      cursor is.  By default, this is unbound.
  488. `kill-word (M-d)'
  489.      Kill from the cursor to the end of the current word, or if between
  490.      words, to the end of the next word.  Word boundaries are the same
  491.      as `forward-word'.
  492. `backward-kill-word (M-DEL)'
  493.      Kill the word behind the cursor.  Word boundaries are the same as
  494.      `backward-word'.
  495. `unix-word-rubout (C-w)'
  496.      Kill the word behind the cursor, using white space as a word
  497.      boundary.  The killed text is saved on the kill-ring.
  498. `delete-horizontal-space ()'
  499.      Delete all spaces and tabs around point.  By default, this is
  500.      unbound.
  501. `yank (C-y)'
  502.      Yank the top of the kill ring into the buffer at the current
  503.      cursor position.
  504. `yank-pop (M-y)'
  505.      Rotate the kill-ring, and yank the new top.  You can only do this
  506.      if the prior command is yank or yank-pop.
  507. File: readline.info,  Node: Numeric Arguments,  Next: Commands For Completion,  Prev: Commands For Killing,  Up: Bindable Readline Commands
  508. Specifying Numeric Arguments
  509. ----------------------------
  510. `digit-argument (M-0, M-1, ... M--)'
  511.      Add this digit to the argument already accumulating, or start a new
  512.      argument.  M- starts a negative argument.
  513. `universal-argument ()'
  514.      Each time this is executed, the argument count is multiplied by
  515.      four.  The argument count is initially one, so executing this
  516.      function the first time makes the argument count four.  By
  517.      default, this is not bound to a key.
  518. File: readline.info,  Node: Commands For Completion,  Next: Keyboard Macros,  Prev: Numeric Arguments,  Up: Bindable Readline Commands
  519. Letting Readline Type For You
  520. -----------------------------
  521. `complete (TAB)'
  522.      Attempt to do completion on the text before the cursor.  This is
  523.      application-specific.  Generally, if you are typing a filename
  524.      argument, you can do filename completion; if you are typing a
  525.      command, you can do command completion, if you are typing in a
  526.      symbol to GDB, you can do symbol name completion, if you are
  527.      typing in a variable to Bash, you can do variable name completion,
  528.      and so on.
  529. `possible-completions (M-?)'
  530.      List the possible completions of the text before the cursor.
  531. `insert-completions ()'
  532.      Insert all completions of the text before point that would have
  533.      been generated by `possible-completions'.  By default, this is not
  534.      bound to a key.
  535. File: readline.info,  Node: Keyboard Macros,  Next: Miscellaneous Commands,  Prev: Commands For Completion,  Up: Bindable Readline Commands
  536. Keyboard Macros
  537. ---------------
  538. `start-kbd-macro (C-x ()'
  539.      Begin saving the characters typed into the current keyboard macro.
  540. `end-kbd-macro (C-x ))'
  541.      Stop saving the characters typed into the current keyboard macro
  542.      and save the definition.
  543. `call-last-kbd-macro (C-x e)'
  544.      Re-execute the last keyboard macro defined, by making the
  545.      characters in the macro appear as if typed at the keyboard.
  546. File: readline.info,  Node: Miscellaneous Commands,  Prev: Keyboard Macros,  Up: Bindable Readline Commands
  547. Some Miscellaneous Commands
  548. ---------------------------
  549. `re-read-init-file (C-x C-r)'
  550.      Read in the contents of your init file, and incorporate any
  551.      bindings or variable assignments found there.
  552. `abort (C-g)'
  553.      Abort the current editing command and ring the terminal's bell
  554.      (subject to the setting of `bell-style').
  555. `do-uppercase-version (M-a, M-b, ...)'
  556.      Run the command that is bound to the corresoponding uppercase
  557.      character.
  558. `prefix-meta (ESC)'
  559.      Make the next character that you type be metafied.  This is for
  560.      people without a meta key.  Typing `ESC f' is equivalent to typing
  561.      `M-f'.
  562. `undo (C-_, C-x C-u)'
  563.      Incremental undo, separately remembered for each line.
  564. `revert-line (M-r)'
  565.      Undo all changes made to this line.  This is like typing the `undo'
  566.      command enough times to get back to the beginning.
  567. `tilde-expand (M-~)'
  568.      Perform tilde expansion on the current word.
  569. `dump-functions ()'
  570.      Print all of the functions and their key bindings to the readline
  571.      output stream.  If a numeric argument is supplied, the output is
  572.      formatted in such a way that it can be made part of an INPUTRC
  573.      file.
  574. File: readline.info,  Node: Readline vi Mode,  Prev: Bindable Readline Commands,  Up: Command Line Editing
  575. Readline vi Mode
  576. ================
  577.    While the Readline library does not have a full set of `vi' editing
  578. functions, it does contain enough to allow simple editing of the line.
  579. The Readline `vi' mode behaves as specified in the Posix 1003.2
  580. standard.
  581.    In order to switch interactively between `Emacs' and `Vi' editing
  582. modes, use the command M-C-j (toggle-editing-mode).  The Readline
  583. default is `emacs' mode.
  584.    When you enter a line in `vi' mode, you are already placed in
  585. `insertion' mode, as if you had typed an `i'.  Pressing ESC switches
  586. you into `command' mode, where you can edit the text of the line with
  587. the standard `vi' movement keys, move to previous history lines with
  588. `k', and following lines with `j', and so forth.
  589.    This document describes the GNU Readline Library, a utility for
  590. aiding in the consitency of user interface across discrete programs
  591. that need to provide a command line interface.
  592.    Copyright (C) 1988, 1994 Free Software Foundation, Inc.
  593.    Permission is granted to make and distribute verbatim copies of this
  594. manual provided the copyright notice and this permission notice pare
  595. preserved on all copies.
  596.    Permission is granted to copy and distribute modified versions of
  597. this manual under the conditions for verbatim copying, provided that
  598. the entire resulting derived work is distributed under the terms of a
  599. permission notice identical to this one.
  600.    Permission is granted to copy and distribute translations of this
  601. manual into another language, under the above conditions for modified
  602. versions, except that this permission notice may be stated in a
  603. translation approved by the Foundation.
  604. File: readline.info,  Node: Programming with GNU Readline,  Next: Concept Index,  Prev: Command Line Editing,  Up: Top
  605. Programming with GNU Readline
  606. *****************************
  607.    This chapter describes the interface between the GNU Readline
  608. Library and other programs.  If you are a programmer, and you wish to
  609. include the features found in GNU Readline such as completion, line
  610. editing, and interactive history manipulation in your own programs,
  611. this section is for you.
  612. * Menu:
  613. * Basic Behavior::    Using the default behavior of Readline.
  614. * Custom Functions::    Adding your own functions to Readline.
  615. * Readline Convenience Functions::    Functions which Readline supplies to
  616.                     aid in writing your own
  617. * Custom Completers::    Supplanting or supplementing Readline's
  618.             completion functions.
  619. File: readline.info,  Node: Basic Behavior,  Next: Custom Functions,  Up: Programming with GNU Readline
  620. Basic Behavior
  621. ==============
  622.    Many programs provide a command line interface, such as `mail',
  623. `ftp', and `sh'.  For such programs, the default behaviour of Readline
  624. is sufficient.  This section describes how to use Readline in the
  625. simplest way possible, perhaps to replace calls in your code to
  626. `gets()' or `fgets ()'.
  627.    The function `readline ()' prints a prompt and then reads and returns
  628. a single line of text from the user.  The line `readline' returns is
  629. allocated with `malloc ()'; you should `free ()' the line when you are
  630. done with it.  The declaration for `readline' in ANSI C is
  631.      `char *readline (char *PROMPT);'
  632. So, one might say
  633.      `char *line = readline ("Enter a line: ");'
  634. in order to read a line of text from the user.  The line returned has
  635. the final newline removed, so only the text remains.
  636.    If `readline' encounters an `EOF' while reading the line, and the
  637. line is empty at that point, then `(char *)NULL' is returned.
  638. Otherwise, the line is ended just as if a newline had been typed.
  639.    If you want the user to be able to get at the line later, (with C-p
  640. for example), you must call `add_history ()' to save the line away in a
  641. "history" list of such lines.
  642.      `add_history (line)';
  643. For full details on the GNU History Library, see the associated manual.
  644.    It is preferable to avoid saving empty lines on the history list,
  645. since users rarely have a burning need to reuse a blank line.  Here is
  646. a function which usefully replaces the standard `gets ()' library
  647. function, and has the advantage of no static buffer to overflow:
  648.      /* A static variable for holding the line. */
  649.      static char *line_read = (char *)NULL;
  650.      
  651.      /* Read a string, and return a pointer to it.  Returns NULL on EOF. */
  652.      char *
  653.      rl_gets ()
  654.      {
  655.        /* If the buffer has already been allocated, return the memory
  656.           to the free pool. */
  657.        if (line_read)
  658.          {
  659.            free (line_read);
  660.            line_read = (char *)NULL;
  661.          }
  662.      
  663.        /* Get a line from the user. */
  664.        line_read = readline ("");
  665.      
  666.        /* If the line has any text in it, save it on the history. */
  667.        if (line_read && *line_read)
  668.          add_history (line_read);
  669.      
  670.        return (line_read);
  671.      }
  672.    This function gives the user the default behaviour of TAB
  673. completion: completion on file names.  If you do not want Readline to
  674. complete on filenames, you can change the binding of the TAB key with
  675. `rl_bind_key ()'.
  676.      `int rl_bind_key (int KEY, int (*FUNCTION)());'
  677.    `rl_bind_key ()' takes two arguments: KEY is the character that you
  678. want to bind, and FUNCTION is the address of the function to call when
  679. KEY is pressed.  Binding TAB to `rl_insert ()' makes TAB insert itself.
  680. `rl_bind_key ()' returns non-zero if KEY is not a valid ASCII character
  681. code (between 0 and 255).
  682.    Thus, to disable the default TAB behavior, the following suffices:
  683.      `rl_bind_key ('\t', rl_insert);'
  684.    This code should be executed once at the start of your program; you
  685. might write a function called `initialize_readline ()' which performs
  686. this and other desired initializations, such as installing custom
  687. completers (*note Custom Completers::.).
  688. File: readline.info,  Node: Custom Functions,  Next: Readline Convenience Functions,  Prev: Basic Behavior,  Up: Programming with GNU Readline
  689. Custom Functions
  690. ================
  691.    Readline provides many functions for manipulating the text of the
  692. line, but it isn't possible to anticipate the needs of all programs.
  693. This section describes the various functions and variables defined
  694. within the Readline library which allow a user program to add
  695. customized functionality to Readline.
  696. * Menu:
  697. * The Function Type::    C declarations to make code readable.
  698. * Function Writing::    Variables and calling conventions.
  699. File: readline.info,  Node: The Function Type,  Next: Function Writing,  Up: Custom Functions
  700. The Function Type
  701. -----------------
  702.    For readabilty, we declare a new type of object, called "Function".
  703. A `Function' is a C function which returns an `int'.  The type
  704. declaration for `Function' is:
  705. `typedef int Function ();'
  706.    The reason for declaring this new type is to make it easier to write
  707. code describing pointers to C functions.  Let us say we had a variable
  708. called FUNC which was a pointer to a function.  Instead of the classic
  709. C declaration
  710.    `int (*)()func;'
  711. we may write
  712.    `Function *func;'
  713. Similarly, there are
  714.      typedef void VFunction ();
  715.      typedef char *CPFunction (); and
  716.      typedef char **CPPFunction ();
  717. for functions returning no value, `pointer to char', and `pointer to
  718. pointer to char', respectively.
  719. File: readline.info,  Node: Function Writing,  Prev: The Function Type,  Up: Custom Functions
  720. Writing a New Function
  721. ----------------------
  722.    In order to write new functions for Readline, you need to know the
  723. calling conventions for keyboard-invoked functions, and the names of the
  724. variables that describe the current state of the line read so far.
  725.    The calling sequence for a command `foo' looks like
  726.      `foo (int count, int key)'
  727. where COUNT is the numeric argument (or 1 if defaulted) and KEY is the
  728. key that invoked this function.
  729.    It is completely up to the function as to what should be done with
  730. the numeric argument.  Some functions use it as a repeat count, some as
  731. a flag, and others to choose alternate behavior (refreshing the current
  732. line as opposed to refreshing the screen, for example).  Some choose to
  733. ignore it.  In general, if a function uses the numeric argument as a
  734. repeat count, it should be able to do something useful with both
  735. negative and positive arguments.  At the very least, it should be aware
  736. that it can be passed a negative argument.
  737.  - Variable: char * rl_line_buffer
  738.      This is the line gathered so far.  You are welcome to modify the
  739.      contents of the line, but see *Note Allowing Undoing::.
  740.  - Variable: int rl_point
  741.      The offset of the current cursor position in `rl_line_buffer' (the
  742.      *point*).
  743.  - Variable: int rl_end
  744.      The number of characters present in `rl_line_buffer'.  When
  745.      `rl_point' is at the end of the line, `rl_point' and `rl_end' are
  746.      equal.
  747.  - Variable: int rl_mark
  748.      The mark (saved position) in the current line.  If set, the mark
  749.      and point define a *region*.
  750.  - Variable: int rl_done
  751.      Setting this to a non-zero value causes Readline to return the
  752.      current line immediately.
  753.  - Variable: int rl_pending_input
  754.      Setting this to a value makes it the next keystroke read.  This is
  755.      a way to stuff a single character into the input stream.
  756.  - Variable: char * rl_prompt
  757.      The prompt Readline uses.  This is set from the argument to
  758.      `readline ()', and should not be assigned to directly.
  759.  - Variable: char * rl_terminal_name
  760.      The terminal type, used for initialization.
  761.  - Variable: char * rl_readline_name
  762.      This variable is set to a unique name by each application using
  763.      Readline.  The value allows conditional parsing of the inputrc file
  764.      (*note Conditional Init Constructs::.).
  765.  - Variable: FILE * rl_instream
  766.      The stdio stream from which Readline reads input.
  767.  - Variable: FILE * rl_outstream
  768.      The stdio stream to which Readline performs output.
  769.  - Variable: Function * rl_startup_hook
  770.      If non-zero, this is the address of a function to call just before
  771.      `readline' prints the first prompt.
  772. File: readline.info,  Node: Readline Convenience Functions,  Next: Custom Completers,  Prev: Custom Functions,  Up: Programming with GNU Readline
  773. Readline Convenience Functions
  774. ==============================
  775. * Menu:
  776. * Function Naming::    How to give a function you write a name.
  777. * Keymaps::        Making keymaps.
  778. * Binding Keys::    Changing Keymaps.
  779. * Associating Function Names and Bindings::    Translate function names to
  780.                         key sequences.
  781. * Allowing Undoing::    How to make your functions undoable.
  782. * Redisplay::        Functions to control line display.
  783. * Modifying Text::    Functions to modify `rl_line_buffer'.
  784. * Utility Functions::    Generally useful functions and hooks.
  785. File: readline.info,  Node: Function Naming,  Next: Keymaps,  Up: Readline Convenience Functions
  786. Naming a Function
  787. -----------------
  788.    The user can dynamically change the bindings of keys while using
  789. Readline.  This is done by representing the function with a descriptive
  790. name.  The user is able to type the descriptive name when referring to
  791. the function.  Thus, in an init file, one might find
  792.      Meta-Rubout:    backward-kill-word
  793.    This binds the keystroke Meta-Rubout to the function *descriptively*
  794. named `backward-kill-word'.  You, as the programmer, should bind the
  795. functions you write to descriptive names as well.  Readline provides a
  796. function for doing that:
  797.  - Function: int rl_add_defun (char *name, Function *function, int key)
  798.      Add NAME to the list of named functions.  Make FUNCTION be the
  799.      function that gets called.  If KEY is not -1, then bind it to
  800.      FUNCTION using `rl_bind_key ()'.
  801.    Using this function alone is sufficient for most applications.  It is
  802. the recommended way to add a few functions to the default functions that
  803. Readline has built in.  If you need to do something other than adding a
  804. function to Readline, you may need to use the underlying functions
  805. described below.
  806. File: readline.info,  Node: Keymaps,  Next: Binding Keys,  Prev: Function Naming,  Up: Readline Convenience Functions
  807. Selecting a Keymap
  808. ------------------
  809.    Key bindings take place on a "keymap".  The keymap is the
  810. association between the keys that the user types and the functions that
  811. get run.  You can make your own keymaps, copy existing keymaps, and tell
  812. Readline which keymap to use.
  813.  - Function: Keymap rl_make_bare_keymap ()
  814.      Returns a new, empty keymap.  The space for the keymap is
  815.      allocated with `malloc ()'; you should `free ()' it when you are
  816.      done.
  817.  - Function: Keymap rl_copy_keymap (Keymap map)
  818.      Return a new keymap which is a copy of MAP.
  819.  - Function: Keymap rl_make_keymap ()
  820.      Return a new keymap with the printing characters bound to
  821.      rl_insert, the lowercase Meta characters bound to run their
  822.      equivalents, and the Meta digits bound to produce numeric
  823.      arguments.
  824.  - Function: void rl_discard_keymap (Keymap keymap)
  825.      Free the storage associated with KEYMAP.
  826.    Readline has several internal keymaps.  These functions allow you to
  827. change which keymap is active.
  828.  - Function: Keymap rl_get_keymap ()
  829.      Returns the currently active keymap.
  830.  - Function: void rl_set_keymap (Keymap keymap)
  831.      Makes KEYMAP the currently active keymap.
  832.  - Function: Keymap rl_get_keymap_by_name (char *name)
  833.      Return the keymap matching NAME.  NAME is one which would be
  834.      supplied in a `set keymap' inputrc line (*note Readline Init
  835.      File::.).
  836. File: readline.info,  Node: Binding Keys,  Next: Associating Function Names and Bindings,  Prev: Keymaps,  Up: Readline Convenience Functions
  837. Binding Keys
  838. ------------
  839.    You associate keys with functions through the keymap.  Readline has
  840. several internal keymaps: `emacs_standard_keymap', `emacs_meta_keymap',
  841. `emacs_ctlx_keymap', `vi_movement_keymap', and `vi_insertion_keymap'.
  842. `emacs_standard_keymap' is the default, and the examples in this manual
  843. assume that.
  844.    These functions manage key bindings.
  845.  - Function: int rl_bind_key (int key, Function *function)
  846.      Binds KEY to FUNCTION in the currently active keymap.  Returns
  847.      non-zero in the case of an invalid KEY.
  848.  - Function: int rl_bind_key_in_map (int key, Function *function,
  849.           Keymap map)
  850.      Bind KEY to FUNCTION in MAP.  Returns non-zero in the case of an
  851.      invalid KEY.
  852.  - Function: int rl_unbind_key (int key)
  853.      Bind KEY to the null function in the currently active keymap.
  854.      Returns non-zero in case of error.
  855.  - Function: int rl_unbind_key_in_map (int key, Keymap map)
  856.      Bind KEY to the null function in MAP.  Returns non-zero in case of
  857.      error.
  858.  - Function: int rl_generic_bind (int type, char *keyseq, char *data,
  859.           Keymap map)
  860.      Bind the key sequence represented by the string KEYSEQ to the
  861.      arbitrary pointer DATA.  TYPE says what kind of data is pointed to
  862.      by DATA; this can be a function (`ISFUNC'), a macro (`ISMACR'), or
  863.      a keymap (`ISKMAP').  This makes new keymaps as necessary.  The
  864.      initial keymap in which to do bindings is MAP.
  865.  - Function: int rl_parse_and_bind (char *line)
  866.      Parse LINE as if it had been read from the `inputrc' file and
  867.      perform any key bindings and variable assignments found (*note
  868.      Readline Init File::.).
  869. File: readline.info,  Node: Associating Function Names and Bindings,  Next: Allowing Undoing,  Prev: Binding Keys,  Up: Readline Convenience Functions
  870. Associating Function Names and Bindings
  871. ---------------------------------------
  872.    These functions allow you to find out what keys invoke named
  873. functions and the functions invoked by a particular key sequence.
  874.  - Function: Function * rl_named_function (char *name)
  875.      Return the function with name NAME.
  876.  - Function: Function * rl_function_of_keyseq (char *keyseq, Keymap
  877.           map, int *type)
  878.      Return the function invoked by KEYSEQ in keymap MAP.  If MAP is
  879.      NULL, the current keymap is used.  If TYPE is not NULL, the type
  880.      of the object is returned in it (one of `ISFUNC', `ISKMAP', or
  881.      `ISMACR').
  882.  - Function: char ** rl_invoking_keyseqs (Function *function)
  883.      Return an array of strings representing the key sequences used to
  884.      invoke FUNCTION in the current keymap.
  885.  - Function: char ** rl_invoking_keyseqs_in_map (Function *function,
  886.           Keymap map)
  887.      Return an array of strings representing the key sequences used to
  888.      invoke FUNCTION in the keymap MAP.
  889. File: readline.info,  Node: Allowing Undoing,  Next: Redisplay,  Prev: Associating Function Names and Bindings,  Up: Readline Convenience Functions
  890. Allowing Undoing
  891. ----------------
  892.    Supporting the undo command is a painless thing, and makes your
  893. functions much more useful.  It is certainly easy to try something if
  894. you know you can undo it.  I could use an undo function for the stock
  895. market.
  896.    If your function simply inserts text once, or deletes text once, and
  897. uses `rl_insert_text ()' or `rl_delete_text ()' to do it, then undoing
  898. is already done for you automatically.
  899.    If you do multiple insertions or multiple deletions, or any
  900. combination of these operations, you should group them together into
  901. one operation.  This is done with `rl_begin_undo_group ()' and
  902. `rl_end_undo_group ()'.
  903.    The types of events that can be undone are:
  904.      enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
  905.    Notice that `UNDO_DELETE' means to insert some text, and
  906. `UNDO_INSERT' means to delete some text.  That is, the undo code tells
  907. undo what to undo, not how to undo it.  `UNDO_BEGIN' and `UNDO_END' are
  908. tags added by `rl_begin_undo_group ()' and `rl_end_undo_group ()'.
  909.  - Function: int rl_begin_undo_group ()
  910.      Begins saving undo information in a group construct.  The undo
  911.      information usually comes from calls to `rl_insert_text ()' and
  912.      `rl_delete_text ()', but could be the result of calls to
  913.      `rl_add_undo ()'.
  914.  - Function: int rl_end_undo_group ()
  915.      Closes the current undo group started with `rl_begin_undo_group
  916.      ()'.  There should be one call to `rl_end_undo_group ()' for each
  917.      call to `rl_begin_undo_group ()'.
  918.  - Function: void rl_add_undo (enum undo_code what, int start, int end,
  919.           char *text)
  920.      Remember how to undo an event (according to WHAT).  The affected
  921.      text runs from START to END, and encompasses TEXT.
  922.  - Function: void free_undo_list ()
  923.      Free the existing undo list.
  924.  - Function: int rl_do_undo ()
  925.      Undo the first thing on the undo list.  Returns `0' if there was
  926.      nothing to undo, non-zero if something was undone.
  927.    Finally, if you neither insert nor delete text, but directly modify
  928. the existing text (e.g., change its case), call `rl_modifying ()' once,
  929. just before you modify the text.  You must supply the indices of the
  930. text range that you are going to modify.
  931.  - Function: int rl_modifying (int start, int end)
  932.      Tell Readline to save the text between START and END as a single
  933.      undo unit.  It is assumed that you will subsequently modify that
  934.      text.
  935. File: readline.info,  Node: Redisplay,  Next: Modifying Text,  Prev: Allowing Undoing,  Up: Readline Convenience Functions
  936. Redisplay
  937. ---------
  938.  - Function: int rl_redisplay ()
  939.      Change what's displayed on the screen to reflect the current
  940.      contents of `rl_line_buffer'.
  941.  - Function: int rl_forced_update_display ()
  942.      Force the line to be updated and redisplayed, whether or not
  943.      Readline thinks the screen display is correct.
  944.  - Function: int rl_on_new_line ()
  945.      Tell the update routines that we have moved onto a new (empty)
  946.      line, usually after ouputting a newline.
  947.  - Function: int rl_reset_line_state ()
  948.      Reset the display state to a clean state and redisplay the current
  949.      line starting on a new line.
  950.  - Function: int rl_message (va_alist)
  951.      The arguments are a string as would be supplied to `printf'.  The
  952.      resulting string is displayed in the "echo area".  The echo area
  953.      is also used to display numeric arguments and search strings.
  954.  - Function: int rl_clear_message ()
  955.      Clear the message in the echo area.
  956.